package com.ecar.common.util;

import java.awt.*;
import java.io.InputStream;

public class LoadFont {

	private static final String PROPERTY_PATH = "font.ttc";

	public static Font loadFont(float fontSize) {
		try (InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(PROPERTY_PATH)) {
			Font dynamicFont = Font.createFont(Font.TRUETYPE_FONT, in);
			return dynamicFont.deriveFont(fontSize);
		} catch (Exception e) {
			e.printStackTrace();
			return new java.awt.Font("宋体", Font.BOLD, (int) fontSize);
		}
	}
}